<template>
	<el-table :data="documents" style="width: 70%">
	    <el-table-column prop="documentName" label="文档名称" width="180" />
	    <el-table-column prop="documentPriority" label="文档优先级" width="120" />
		<el-table-column prop="documentState" label="文档状态" width="120"/>
	    <el-table-column prop="documentDate" label="文档结束日期" width="180"/>
		<el-table-column fixed="right" label="操作" width="120">
		    <template #default="scope">
		        <el-button link type="primary" size="small" @click.prevent="showTask(scope.$index)" ><!-- deleteRow(scope.$index) -->
					查看
		        </el-button>
		    </template>
		</el-table-column>
	</el-table>

	<el-dialog v-model="documentDialogVisible" title="文档信息">
		文档名称：{{documents[num].documentName}}<br>
		文档内容：{{documents[num].documentContent}}<br />
		文档状态：{{documents[num].documentState}} | 文档优先级：{{documents[num].documentPriority}}<br />
		<el-form-item label="文档反馈信息">
		      <el-input placeholder="请输入反馈信息" v-model="documents[num].documentFeedback" />
		</el-form-item>
		文档结束日期：{{documents[num].documentDate}}<br>
		<el-button type="primary" @click="updateTaskSubmit">确认</el-button>
		<el-button type="primary" @click="documentDialogVisible=false">取消</el-button>
	</el-dialog>

</template>

<script>
	import qs from 'qs'
	export default {
			data() {
				return {
					documents:[],
					documentDialogVisible:false,
					num:0,
					documentuser:{},
					document:{},
				}
			},
			methods: {
				showTask(index) {
					this.num=index
					this.documentuser.documentId=this.documents[index].documentId
					this.documentDialogVisible=true

				},
				updateTaskSubmit(){
					let that=this
					let s=qs.stringify(that.documents[that.num])
					this.$axios.get("http://localhost:8080/document/documentupdate?"+s).then(function(res){
						that.documentDialogVisible=false
					})
				}
			},
			created() {
				let u=JSON.parse(sessionStorage.getItem("user"))
				let that=this
				that.document.userId=u.userId
				let str=qs.stringify(that.document)
				this.$axios.get("http://localhost:8080/documentuser/showlist?"+str).then(function(res){
					that.documents=res.data
				})
			}
	}
</script>

<style>
</style>
